// Functions associated with the EndPosition class
//-----------------

//-----------------
// Includes libraries and other files
#include "EndPosition.h"
//-----------------

//-----------------
//// CONSTRUCTOR - EndPosition
EndPosition::EndPosition()
	: position_()
{}

//// CONSTRUCTOR - EndPosition
EndPosition::EndPosition( const float& x, const float& y, const float& z)
	: position_( x, y, z)
{}

//// CONSTRUCTOR - EndPosition
EndPosition::EndPosition( const D3DXVECTOR3& pos)
	: position_( pos)
{}

//// CONSTRUCTOR - EndPosition
EndPosition::EndPosition( const EndPosition& ep)
	: position_( ep.get_position())
{}

//// DESTRUCTOR - ~EndPosition
EndPosition::~EndPosition() {}
//-----------------

//-----------------
//// FUNCTION - get_x
// return the x position of the end location
float EndPosition::get_x() const { return position_.x; }

//// FUNCTION - get_y
// return the y position of the end location
float EndPosition::get_y() const { return position_.y; }

//// FUNCTION - get_z
// return the z position of the end location
float EndPosition::get_z() const { return position_.z; }

//// FUNCTION - get_position
// return the x, y and z position of the end location as a vector
D3DXVECTOR3 EndPosition::get_position() const { return position_; }

//// FUNCTION collision
// return true if the parameter is within the end position
bool EndPosition::collision( const D3DXVECTOR3& pos) const {
	// Pre-conditions :- none
	assert( true);

	// As this function compares floats, the tolerance of the y position ensures that it will
	// still collide correctly. Even if different 'floors' are implemented later, the tolerance
	// value should not interfer if the player moves around on a floor above or below where the
	// end position is.
	if( (pos.x > position_.x) && (pos.x < position_.x + GRID_SIZE) && 
		(pos.y > position_.y - 2.5) && (pos.y < position_.y + 2.5) &&
		(pos.z > position_.z) && (pos.z < position_.z + GRID_SIZE))
		return true;
	else
		return false;
}

//// FUNCTION - set_x
// set the x position of the end location
void EndPosition::set_x( const float& x) {
	// Pre-conditions :- none
	assert( true);

	position_.x = x;
}

//// FUNCTION - set_y
// set the y position of the end location
void EndPosition::set_y( const float& y) {
	// Pre-conditions :- none
	assert( true);

	position_.y = y;
}

//// FUNCTION - set_z
// set the z position of the end location
void EndPosition::set_z( const float& z) {
	// Pre-conditions :- none
	assert( true);

	position_.z = z;
}

//// FUNCTION - set_position
// set the x, y and z position of the end location
void EndPosition::set_position( const D3DXVECTOR3& pos) {
	// Pre-conditions :- none
	assert( true);

	position_ = pos;
}